import memberApi from '@/api/declaration/mall/memberApi'
import httpRequest from '@/config/axios/httpRequest'
import {
  MemberAnalyseReqModel,
  MemberRegisterCountRespModel,
  MemberSummaryRespModel
} from '@/models/mall/MemberAnalyseReqModel'
import { formatDate } from '@/utils/formatTime'
import dayjs from 'dayjs'

// 查询会员统计
export const getMemberSummary = () => {
  return httpRequest.get<MemberSummaryRespModel>(memberApi.GetMemberSummary)
}

// 查询会员分析数据
export const getMemberAnalyse = (params: MemberAnalyseReqModel) => {
  return httpRequest.get(memberApi.GetMemberAnalyse, { params })
}

// 按照省份，查询会员统计列表
export const getMemberAreaStatisticsList = () => {
  return httpRequest.get(memberApi.GetMemberAreaStatisticsList)
}

// 按照性别，查询会员统计列表
export const getMemberSexStatisticsList = () => {
  return httpRequest.get(memberApi.GetMemberSexStatisticsList)
}

// 按照终端，查询会员统计列表
export const getMemberTerminalStatisticsList = () => {
  return httpRequest.get(memberApi.GetMemberTerminalStatisticsList)
}

// 获得用户数量量对照
export const getUserCountComparison = () => {
  return httpRequest.get(memberApi.GetUserCountComparison)
}

// 获得会员注册数量列表
export const getMemberRegisterCountList = (
  beginTime: dayjs.ConfigType,
  endTime: dayjs.ConfigType
) => {
  return httpRequest.get<MemberRegisterCountRespModel[]>(memberApi.GetMemberRegisterCountList, {
    params: {
      beginTime: formatDate(dayjs(beginTime).toDate()),
      endTime: formatDate(dayjs(endTime).toDate())
    }
  })
}
